module dogre.quaternion;

import std.stdio;

extern(C)
{
	void *getQuaternion(float, float, float, float);
	float* call_Quaternion_ptr(void* ptr);
}

class Quaternion
{
	void* p;
	float* p_w;
	
	this(float fW = 1.0, float fX = 0.0, float fY = 0.0, float fZ = 0.0)
	{
		p = getQuaternion(fW, fX, fY, fZ);
		p_w = call_Quaternion_ptr(p);
	}
    this(void* ptr)
    {
        assert(ptr);
        p = ptr;
        p_w = call_Quaternion_ptr(p);
    }
	
	@property float w()
	{
		return *p_w;
	}
	
	@property void w(float value)
	{
		*p_w = value;
	}
	
	@property float x()
	{
		return *(p_w+1);
	}
	
	@property void x(float value)
	{
		*(p_w+1) = value;
	}
	
	@property float y()
	{
		return *(p_w+2);
	}
	
	@property void y(float value)
	{
		*(p_w+2) = value;
	}
	
	@property float z()
	{
		return *(p_w+3);
	}
	
	@property void z(float value)
	{
		*(p_w+3) = value;
	}
	
	static Quaternion IDENTITY()
	{
		return new Quaternion(1.0, 0.0, 0.0, 0.0);
	}
	
	static Quaternion ZERO()
	{
		return new Quaternion(0.0, 0.0, 0.0, 0.0);
	}
}